package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    EditText etX;
    EditText etY;
    Button btn;
    TextView tvResult;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setViews();
    }
    public void setViews(){
        etX = (EditText)findViewById(R.id.edX);
        etY = (EditText)findViewById(R.id.edY);
        btn = (Button)findViewById(R.id.btn);
        tvResult = (TextView)findViewById(R.id.tvResult);
        btn.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        int x = Integer.parseInt(etX.getText().toString());
        int y = Integer.parseInt(etY.getText().toString());
        int z = x+y;
        tvResult.setText("获得结果:" + z);
    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {
        super.onPointerCaptureChanged(hasCapture);
    }
}
